package com.atguigu.gmall.all.controller;


import com.atguigu.gmall.cart.client.CartFeignClient;
import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.cart.CartInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping
public class CartController {



    @Autowired
    private CartFeignClient cartFeignClient;

    @GetMapping("/addCart.html")
    public String addCart(Long skuId, Integer skuNum, Model model){

        Result<CartInfo> result = cartFeignClient.addToCart(skuId, skuNum);

        model.addAttribute("cartInfo",result.getData());
        model.addAttribute("skuNum",skuNum);

        return "cart/addCart";
    }

    //去购物车
    @GetMapping("/cart.html")
    public String cart(){
        return "cart/index";
    }

}
